#pragma once

#include <string>
#include <list>
#include <memory>

#include "LogEvent.h"
#include "LogAppender.h"

namespace bamboo {

//日志器
class Logger {
public:
    typedef std::shared_ptr<Logger> ptr;

    Logger(const std::string& name = "root") : m_name(name) {
        m_level = LogLevel::DEBUG;
        StdoutLogAppender::ptr appender(new StdoutLogAppender());
        addAppender(appender);
    }

    void setLevel(LogLevel::Level level) { m_level = level; }
    LogLevel::Level getLevel() { return m_level; }

    void log(LogEvent::ptr event);

    void addAppender(LogAppender::ptr appender);
    void delAppender(LogAppender::ptr appender);

    void debug(LogEvent::ptr event);
    void info(LogEvent::ptr event);
    void warn(LogEvent::ptr event);
    void error(LogEvent::ptr event);
    void fatal(LogEvent::ptr event);
private:
    std::string     m_name;                     //日志名称
    LogLevel::Level m_level;                    //日志等级
    std::list<LogAppender::ptr> m_appenders;    //Appender集合
};

}   //namespace bamboo